package com.kun.kunkunmall.order.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

@ConfigurationProperties(prefix = "alipay")
@Component
public class AlipayConfig {
	// 商户appid
	public static String APPID = "9021000123613600";
	// 私钥 pkcs8格式的
	public static String RSA_PRIVATE_KEY = "MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC7BHXFMo2mTNRhhQ5umjjLwDHysbK3sY2tz0VVbUen98rX1/hwh+hHIikMzY2Gb+uHt8YYGJsI3gWL3viskW1l0WAkiZq/oOjotD3E9FXe0fR+GhYfiiuwuLMRv8kVjhJD1Ui9eSauglVP95q4TCd5hHNN/b+QwBox/by1zmQu0BS7pKBNMYKdd1fYaNwcLkASr6BIOKAD4rolPDLeK/Zg2G+O2qFcpJPMq+3/j9U8nIc5IPVtk06aGPlzYBqg7/6RbAoy0S1Yy1L4FmXDDduHa6UpX+i7F4uGsJY1ObXFhOYLOaUPD5DriXvtZdORW+cEvQhGp+IGY2975aJlSfNFAgMBAAECggEASgUa4+D9ZYvVJ3/1VVtfDW3Vlxw0AzaYP+ngpE4rZVTTCRkm8Msp6TWhD7svv7z+eOoI0rKychEGGvU2cX7h0MHNDskT4bK7XJcyN4kJj7aD0YFbrkIOxtRjs6u31/sySXzaXHveDoXxZEQ5Daa+nP8KcBz1vEH8XDr0fPTifBAbF9qguOR2w491IHSHVc4yy/Tqf38fEjXLTDqqgYwbMnN1eYBY+hehnkzC9G1uwfrshw5zCztDsuJUWxTA9MaDCH5xLLkwqZFy414r6kA53SdjGHvOh3IfdFIVLjitxAYvb81tJrWM4bzAzYgxVr/tzOJyrd2i8083L9IdG6S2pQKBgQD3FbmrcpzDQIXgVSAz99mFjXin3bJEwttW4jwO/D1tzbGQ3AgpgcO+CFivNb78K4zDKlIVcIOI+vPcjKpzy/rxyT6sKbOTzvCGwa/k5hYYo5Gqh/Q7ADHxnqPc8SaZCcZA8v6qTcWab1G9jVG+AhztLfCDTPhRlmBYGPxki0drSwKBgQDBw+dMk7Ur7Nr1QjBzD70C+rOqI3g1SJSImNqhKVSGhDkUW7yznoL2BT3itLERIU9CjY9TUwzDM8RAzTxeDORQP5xj9J+TIr0x9P7zqKYzP5WQAPnqPH6EaqUcWcxjjvfXxg9T+OVCrGc/yeq+Mm6wSPHjkc7mrRTrmIw+aqLxrwKBgA1ODS5vQIO/ELZwvwgtW3g2kv2vEW9kcr0t93/zEze7cMlVH9dkVm8AMg5VPZCEo9LKj5r58QtKQCFrLa6ImF22sXpB0Jqv9QG8okUYIq52+FwPcBZRP188ZKR8E9D/1r4el5oCEBbt0Z/8YR9zK62V4LKhTWnPSCbWSZj8av8bAoGAYbZB+OrvzOPXkyC6v/tqzIrSeXUDlJMyXCQA9I6cEm2xPyP35/iCgEAqch2+wS20A5LReSqDYBjF2gvlamRD6nf5jKp6oj89e2jZ/NPKZEOnT4Q+gzHYdzw0YTSjjn01XLmDV0xHiLTaKF/RofJawUk3uhP4a3lS+G/oIT2zR/8CgYBKRUpSCwYpyscnQamurLkoNxi0P7/ag113r4u/nkPJiuBrzBZqI4MDPYKN5z8bx23emouuxKse0jwmj8VTfD4eM6ywOQgQuvo5+05hW8zBvaKPeoLuQzaPIr5DR7WX8L0HUXPhz9b86JASTLfLpvX4610ghPx/OETUHMXgKTkosQ==";
	// 服务器异步通知页面路径 需http://或者https://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
	public static String notify_url = "http://7b3bf60f.r1.cpolar.top/payed/notify";
	// 页面跳转同步通知页面路径 需http://或者https://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问 商户可以自定义同步跳转地址
	public static String return_url = "http://member.kunkunmall.com/memberOrder.html";
	// 请求网关地址
	public static String URL = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";
	// 编码
	public static String CHARSET = "UTF-8";
	// 返回格式
	public static String FORMAT = "json";
	// 支付宝公钥
	public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApFK5DhJqDXbXr8If1o/vVyJ04TkQ5x0Z8Yup09x+zLSlSwhon4w7zoYLwwrBFrnEJeR1MZ5OM+dS7uD4HwwmAiGng2m8p+5ekrpaOWUxDWTL30Ca8em02ZUBx9+jKU/LQdOF3AJWNcWERfhujZlrtKwCorBTc6Sw5HvBa7WfD+UmeCaUPeoDF9NAdDntLeqG4Invr1BedIbhrSwAxpUw26LM+wZ6Zl4A02eYs/CnJkejaH2QAoEWS+HymSq04b/tlHOo8XXV9fpkeUcbK/2EPFT6JMbxk0dFKmgKpEBCsaSHz671PLN19BWTf4YMLyOunfa0kDo8EcnLxmYuTtJC3wIDAQAB";
	// 日志记录目录
	public static String log_path = "/log";
	// RSA2
	public static String SIGNTYPE = "RSA2";

	/**
	 * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
	 * @param sWord 要写入日志里的文本内容
	 */
	public static void logResult(String sWord) {
		FileWriter writer = null;
		try {
			writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
			writer.write(sWord);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (writer != null) {
				try {
					writer.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}
}
